package com.ygl.strategy.service.opentracing.configuration;

import com.ygl.strategy.constant.StrategyConstant;
import com.ygl.strategy.service.configuration.ServiceStrategyAutoConfiguration;
import com.ygl.strategy.service.opentracing.tracer.DefaultServiceStrategyOpentracingTracer;
import com.ygl.strategy.service.tracer.ServiceStrategyTracer;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * author: yanggld
 * date: 2019/12/22 19:32
 * version: 1.0
 * description: ServiceStrategyOpentracingAutoConfiguration
 */
@Configuration
@AutoConfigureBefore(ServiceStrategyAutoConfiguration.class)
@ConditionalOnProperty(value = StrategyConstant.SPRING_APPLICATION_STRATEGY_CONTROL_ENABLED, matchIfMissing = true)
public class ServiceStrategyOpentracingAutoConfiguration {
    @Bean
    @ConditionalOnProperty(value = StrategyConstant.SPRING_APPLICATION_STRATEGY_TRACE_ENABLED, matchIfMissing = false)
    public ServiceStrategyTracer serviceStrategyTracer() {
        return new DefaultServiceStrategyOpentracingTracer();
    }
}